<?php
#                                                                                 
# author: Cody Sorgenfrey                                       
# (c)2013 South Hill Calvary Chapel                                               
# 
include_once("./root.inc.php");
include_once("${root}/mysql/database_info.php");
include_once("${root}/mysql/common.php");
include_once("${root}/common.php");
include_once("registrationManagerFunctions.php"); 
$title = "2013 Family Camp Payment";
$meta_key='';
$meta_desc="";
print_html_head($title ,$meta_key,$meta_desc);
print_java_head("<script type='text/javascript' src='/js/registrationManager.js'></script>");
connect_select_test("events");
begin_body();
page_title($title);
$event = mysql_fetch_array(mysql_query("SELECT * FROM `events` WHERE `id`='326'"));
$list = file_get_contents("owes.csv");
$families = explode("\n", $list);
?>
<script type="text/javascript">
	function redirect(obj)
	{
		var amount = parseFloat(obj.options[obj.options.selectedIndex].value.substr(1));
		amount = amount+(amount*.023)+.30;
		amount = amount.toFixed(2);
		var vars = 
		obj.options[obj.options.selectedIndex].text+"_"+
		" "+"_"+
		" "+"_"+
		" "+"_"+
		"Payment Only"+"_"+
		"Paypal"+"_"+
		amount+"_"+
		"1"+"_"+
		"0"+"_"+
		"0"+"_"+
		"0"+"_"+
		"1";
		var uri = "https://www.paypal.com/cgi-bin/webscr";
		uri += "?cmd=_xclick";
		uri += "&business=paypal%40southhillcalvary.org";
		uri += "&amount="+amount;
		uri += "&lc=US";
		uri += "&no_note=1";
		uri += "&no_shipping=2";
		uri += "&rm=1";
		uri += "&currency_code=USD";
		uri += "&page_style=SHCC";
		uri += "&item_name=2013+Family+Camp+Payment";
		uri += "&item_number=shcc-326";
		uri += "&notify_url=http://www.southhillcalvary.org/cody/registrationBackend.php";
		uri += "&custom=326_"+ encodeURIComponent(vars);
		window.location = uri;
	}
</script>
<form>
<p>Please select the name associated with your registration below to pay for your spot.</p>
<select name="families">
<?
	for ($x=0;$x<count($families);$x++){
		$parts = explode(",", $families[$x]);
		printf("<option value='%s'>%s</option>\n",$parts[2] ,$parts[0]." - ".$parts[1]);
	}
?>
</select>
<input type="submit" onclick="event.preventDefault();redirect(this.previousSibling.previousSibling)">
</form>
<?
end_page_title();
end_body();
?>